package org.biloxi.player.impl;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.List;

import org.biloxi.model.Deck;
import org.biloxi.model.GameState;
import org.biloxi.model.GameState.Phase;
import org.biloxi.model.magicobjects.MagicObject;
import org.biloxi.model.magicobjects.impl.Plains;
import org.biloxi.model.magicobjects.impl.Swamp;
import org.biloxi.model.magicobjects.impl.VenomousDragonFly;
import org.biloxi.model.player.PlayerState;
import org.biloxi.model.player.Zone;
import org.biloxi.player.Player;
import org.biloxi.player.PlayerID;
import org.biloxi.player.actions.ActionOptionPair;
import org.biloxi.player.actions.PlayerActionRepository;

public class ComputerPlayer extends Player {

	private final PlayerID _id;
	private final Deck _deck = new Deck();
	
	public ComputerPlayer(PlayerActionRepository acts, String id) {
		super(acts);

		_deck.cards.add(Swamp.class.getSimpleName());
		_deck.cards.add(VenomousDragonFly.class.getSimpleName());
		_deck.cards.add(Plains.class.getSimpleName());
		
		_id = new PlayerID(id);
	}
	
	protected void printZone(String zName, Zone z){
		System.out.println(zName);
		for(MagicObject mo : z.getMagicObjects()){
			System.out.println("\tcardId:"+mo.getCardID()+" "+mo.getCardName()+" - "+mo.getDescription());
		}
	}

	public ActionOptionPair<?>[] getAction(GameState gameState, PlayerState playerState) {
		//if(gameState.getPhase() == Phase.Upkeep){
			//TODO remove this debug info
			//only print out the info during upkeep
			System.out.println("PlayerID:"+getID().toString());
			System.out.println("PHASE:"+gameState.getPhase().toString());
			System.out.println("-----------------");
			printZone("LIBRARY", playerState.getLibrary());
			printZone("HAND", playerState.getHand());
			printZone("IN_PLAY", playerState.getInPlay());
			System.out.println("-----------------\n");
		//}
		
		if(gameState.getPhase() == Phase.Draw){
			//draw a card
			return new ActionOptionPair<?>[]{actions.drawCard.do_(null)};
		}else if(gameState.getPhase() == Phase.Main1){
			return null;
		}else{
			return null;
		}
	}

	public Deck getDeck() {
		return _deck;
	}

	public PlayerID getID() {
		return _id;
	}

}
